package com.nursing.service;

import com.nursing.Dao.HealthRecordDao;
import com.nursing.bean.HealthRecord;
import org.springframework.stereotype.Service;

@Service
public class HealthRecordService {
    private final HealthRecordDao healthRecordDao;

    public HealthRecordService(HealthRecordDao healthRecordDao) {
        this.healthRecordDao = healthRecordDao;
    }

    public HealthRecord getHealthRecordByElderId(Integer elderId) {
        return healthRecordDao.getByElderId(elderId);
    }

    public void createOrUpdateHealthRecord(HealthRecord healthRecord) {
        if(healthRecord.getId() == null) {
            healthRecordDao.insert(healthRecord);
        } else {
            healthRecordDao.update(healthRecord);
        }
    }
}
